home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Libraries / Mail / Includes / UMailer.h < prev    next >
Encoding:
Text File  |  1996-04-03  |  8.2 KB  |  313 lines  |  [TEXT/MPS ]

  1. // UMailer.h
  2. // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
  3.  
  4.  
  5. #ifndef __UMAILER__
  6. #define __UMAILER__
  7.  
  8. #if qPowerTalk
  9.  
  10. // MacApp
  11.  
  12. #ifndef __UOBJECT__
  13. #include "UObject.h"
  14. #endif
  15.  
  16. #ifndef __USCRIPTABLEOBJECT__
  17. #include "UScriptableObject.h"
  18. #endif
  19.  
  20. // Toolbox
  21.  
  22. #ifndef __OCESTANDARDMAIL__
  23. #include <OCEStandardMail.h>
  24. #endif
  25.  
  26. class MMailable;
  27. class TAppleEvent;
  28. class TDocument;
  29. class TFileBasedDocument;
  30. class TLetterTabber;
  31. class TMailer;
  32. class TMailerView;
  33. class TWindow;
  34.  
  35. //----------------------------------------------------------------------------------------
  36. // TLetter
  37. //----------------------------------------------------------------------------------------
  38.  
  39. // Represents the letter enclosing a document. 
  40. // Contains the mailers, which contain recipients. 
  41.  
  42. class TLetter : public TObject
  43. {
  44.     MA_DECLARE_CLASS;
  45.  
  46. public:
  47.     MMailable* fMailDoc;                     // Enclosed document. 
  48.  
  49.     TDocument* fDocument;                     // Enclosed document. 
  50.     
  51.     TLetterTabber *fLetterTabber;            // Tabber responsible for the window containing
  52.                                             // the mailer view
  53.  
  54.     Handle fLetterDescriptor;                // Handle to a LetterDescriptor
  55.         
  56.     Boolean fHasMailer;                     // Does this document have a mailer attached.
  57.  
  58.     Boolean fHasBeenSent;                    // Has been sent as a letter
  59.  
  60.     Boolean fLetterExists;                    // Does this document represent an existing letter?
  61.     
  62.     Boolean fReplyToAll;                    // True if reply to all. False if reply to sender only.
  63.     
  64.     TLetter();
  65.         // Constructor
  66.  
  67.     virtual ~TLetter();
  68.         // Destructor
  69.  
  70.     void ILetter(MMailable* mailDoc);
  71.     
  72.     
  73.     virtual void AddMailer();
  74.         // Add a mailer to this document
  75.  
  76.     virtual void AddNativeMailContent(Boolean& okToSend);
  77.         // Called to put the document's content into the letter in the document's
  78.         // native format.
  79.  
  80.     virtual void AddSnapshotMailContent(Boolean& okToSend);
  81.         // Called to create a snapshot of the document and add this to the letter.
  82.         // Default implementation takes a snapshot of the mailer window. 
  83.  
  84.     virtual void AddStandardMailContent(Boolean& okToSend);
  85.         // Called to put the document's content into the letter in the standard mail
  86.         // format.
  87.  
  88.     long CountContainedMailers();
  89.  
  90.     virtual void DeleteMailer();
  91.         // Remove the mailer from this document
  92.  
  93.     virtual void DoAECreateMailer(TAppleEvent* message,
  94.                                   TAppleEvent* reply);
  95.         // Adds a mailer to this document.
  96.  
  97.     virtual void DoAECreateReply(TAppleEvent* message,
  98.                                  TAppleEvent* reply);
  99.         // Handles creating a reply mailer in this document.
  100.  
  101.     virtual void DoAESend(TAppleEvent* message,
  102.                           TAppleEvent* reply);
  103.         // Handles the send event
  104.  
  105.     virtual void DoForward();
  106.         // Forward this document to a new address.
  107.  
  108.     virtual Boolean DoMailMenuCommand(CommandNumber aCommandNumber);
  109.         // Handles the default menu commands associated with a mailable document.
  110.  
  111.     virtual void DoReply();
  112.         // Create a new document in reply to this one.
  113.  
  114.     virtual void DoSend();
  115.         // Tell this document to send itself. 
  116.  
  117.     virtual Boolean ValidateForSend();
  118.         // Validate the contents of the subject and recipient fields before mailing.
  119.     
  120.     virtual Boolean DoSendOptions(Ptr shouldSend,
  121.                                   Ptr sendOptions,
  122.                                   CStr255& nativeFormatName);
  123.         // Displays the send options dialog.
  124.  
  125.     virtual void DoSetupMailMenus();
  126.         // Set up the mail menu. 
  127.  
  128.     virtual void GetDefaultTag(CStr31& tagString);
  129.         // Get the default tag to show when closing letters. 
  130.  
  131.     virtual TMailer* GetIndContainedMailer(short index);
  132.     
  133.     virtual TMailerView* GetMailerView();
  134.         // Returns the TMailerView assocatiated with the letter
  135.         
  136.     virtual TWindow* GetMailerWindow();
  137.         // Returns the document's window that should be used for the mailer. 
  138.  
  139.     virtual WindowRef GetMailerWindowRef();
  140.         // Returns the toolbox window that should be used for the mailer. 
  141.  
  142.     virtual Boolean HasMailer();
  143.         // Does this letter have a mailer attached?
  144.  
  145.     virtual void LetterContentChanged();
  146.         // Tells the SMP that the document contents have changed. 
  147.     
  148.     virtual void MakeRoomForMailer(long amount, Boolean redraw);
  149.         // Adjust the views to make room for the mailer
  150.  
  151.     virtual void OpenLetter();
  152.         // Creates a mailer and reads the content from the mail system.
  153.  
  154.     virtual void ReadLetter(Boolean forPrinting);
  155.         // Override to read a letter.
  156.  
  157.     virtual Boolean ReadNativeMailContent();
  158.         // Called from OpenLetter to read the content in the document's native format.
  159.         
  160.     virtual Boolean ReadSnapshotMailContent();
  161.         // Called from OpenLetter to read the content in the snapshot format.
  162.  
  163.     virtual Boolean ReadStandardMailContent();
  164.         // Called from OpenLetter to read the content in the standard format.
  165.  
  166.  
  167.     virtual void SaveLetter(CommandNumber itsCommandNumber);
  168.         // Try to save the document to disk as a letter
  169.  
  170.     virtual void SendDocument(Ptr theSendOptions,
  171.                               unsigned long whichFormats,
  172.                               CStr255& nativeFormatName);
  173.         // Sends the document.
  174.  
  175.     virtual void SetLetterDesc(Handle theDesc);
  176.         // Associated this document with a LetterSpecifier. Called from 
  177.         // TApplication::OpenOldLetters and TFileBasedDocument::ReadLetter when 
  178.         // opening letters from the mail and file systems.
  179.         
  180.  
  181. };
  182.  
  183. //----------------------------------------------------------------------------------------
  184. // TFileBasedLetter
  185. //----------------------------------------------------------------------------------------
  186.  
  187. // Represents the letter enclosing a file-based document. 
  188.  
  189. class TFileBasedLetter : public TLetter
  190. {
  191.     MA_DECLARE_CLASS;
  192.  
  193. public:
  194.     TFileBasedDocument* fFileBasedDocument;            // Enclosed document. 
  195.  
  196.     TFileBasedLetter();
  197.         // Constructor
  198.  
  199.     virtual ~TFileBasedLetter();
  200.         // Destructor
  201.  
  202.     void IFileBasedLetter(MMailable* mailDoc);
  203.  
  204.     virtual void AddNativeMailContent(Boolean& okToSend); // override
  205.         // Saves the document in a temporary file then adds it as the main enclosure to
  206.         // the letter.
  207.  
  208.     virtual void ReadLetter(Boolean forPrinting); // override
  209.         // Called to read an existing letter from HFS for display or printing.
  210.  
  211.     virtual Boolean ReadNativeMailContent(); // override
  212.         // Reads the document from the mail enclosure file in the letter.
  213.         
  214.     virtual void SaveLetter(CommandNumber itsCommandNumber); // override
  215.         // Try to save the document to disk as a letter.
  216.  
  217. };
  218.  
  219. //----------------------------------------------------------------------------------------
  220. // TMailer
  221. //----------------------------------------------------------------------------------------
  222.  
  223. // OSL Accessor class for one of the mailers attached to a document.
  224.  
  225. class TMailer : public TObject, 
  226.                 public MScriptableObject
  227. {
  228.     MA_DECLARE_CLASS;
  229.  
  230. public:
  231.     WindowRef    fWindow;
  232.     TDocument*    fDocument;
  233.     TLetter*    fLetter;
  234.     short        fWhichMailer;
  235.     
  236.     TMailer();
  237.     virtual ~TMailer();
  238.         // Destructor
  239.  
  240.      void IMailer(TLetter* letter,
  241.                     WindowRef theWindow,
  242.                     short whichMailer);
  243.  
  244.      Boolean TopMailer();
  245.  
  246.      virtual MScriptableObject* GetObjectsContainer();
  247.  
  248.      virtual Boolean GetObjectProperty(CAEDesc& thePropertyValue,
  249.                                DescType whichProperty,
  250.                                const CAEDesc& desiredType);
  251.  
  252.      virtual void SetObjectProperty(const CAEDesc& thePropertyValue,
  253.                                         DescType whichProperty);
  254.  
  255.      virtual MScriptableObject* GetIndContainedObject(DescType desiredType,
  256.                                                           long index);
  257.  
  258.      virtual long CountContainedObjects(DescType desiredType);
  259.  
  260.      virtual void DoAEDelete(TAppleEvent* message,
  261.                      TAppleEvent* reply);
  262. };
  263.  
  264. //----------------------------------------------------------------------------------------
  265. // TRecipient
  266. //----------------------------------------------------------------------------------------
  267.  
  268. // OSL Accessor class for one of the recipients in a mailer.
  269.  
  270. class TRecipient :     public TObject, 
  271.                     public MScriptableObject
  272. {
  273.  
  274.     MA_DECLARE_CLASS;
  275.  
  276. public:
  277.     WindowRef fWindow;
  278.     TMailer* fMailer;
  279.     long fWhichRecipient;
  280.     
  281.     TRecipient();
  282.     virtual ~TRecipient();
  283.         // Destructor
  284.  
  285.      void IRecipient(TMailer* theMailer,
  286.                      long index,
  287.                      WindowRef theWindow);
  288.  
  289.      virtual MScriptableObject* GetObjectsContainer();
  290.  
  291.      virtual Boolean GetObjectProperty(CAEDesc& thePropertyValue,
  292.                                DescType whichProperty,
  293.                                const CAEDesc& desiredType);
  294.  
  295.      void SetObjectProperty(const CAEDesc& thePropertyValue,
  296.                             DescType whichProperty);
  297.  
  298.  
  299. };
  300.  
  301. //----------------------------------------------------------------------------------------
  302.  
  303. // Globals for this unit
  304.  
  305. extern void InitUMailer();
  306.     // Sets up proc pointers and does general initialization
  307.  
  308. extern SMPDrawImageUPP gMacAppImageProc;
  309.  
  310. #endif // qPowerTalk
  311.  
  312. #endif // __UMAILER__
  313.